Skip to content

Updated the runlist timeout path to get correct command idx#1189

Merged
chvamshi-xilinx merged 2 commits intoamd:mainfrom
bisingha-xilinx:runlist-timeout-path-update
Mar 23, 2026
Merged

Updated the runlist timeout path to get correct command idx#1189
chvamshi-xilinx merged 2 commits intoamd:mainfrom
bisingha-xilinx:runlist-timeout-path-update

Conversation

@bisingha-xilinx
Copy link
Contributor

Problem

When a runlist (command chain) times out, the driver was hardcoding error_index = 0, causing XRT to always report the first sub-command as the timed-out command — regardless of which sub-command actually hung. This made it impossible for userspace to identify the real offending command in a multi-command runlist.

Root Cause

In the timeout path of ve2_cmd_wait(), the driver unconditionally set cc->error_index = 0 with a comment stating this was intentional for the async/timeout case. Unlike the normal error path (where CERT writes completion status per slot), the timeout path fires before CERT has a chance to write per-slot completion. However, CERT does maintain a runlist_read_idx field in the handshake struct (offset 0x70) that tracks how many sub-commands have been processed, which was not being utilized.

Fix

Read runlist_read_idx from the CERT handshake memory via ve2_partition_read_privileged_mem() in the timeout path to determine the actual failing sub-command index. This mirrors the approach already used in the AIE4 driver (aie4_hwctx.c).

Changes

  • ve2_hwctx.c — Replaced the hardcoded cc->error_index = 0 in the timeout path with a read of runlist_read_idx from CERT handshake memory (col 0, offset 0x70). The value is bounds-checked against cmd_count and falls back to 0 if out of range or if the privileged memory read fails. Added an XDNA_ERR log with the failing index, slot, and raw runlist_read_idx for diagnostics.
  • ve2_host_queue.h — Renamed completion_status to runlist_read_idx in struct handshake to accurately reflect the field's purpose as defined by the CERT firmware.
  • ve2_mgmt.c — Updated ve2_dump_debug_state() to print the renamed runlist_read_idx field.

Testing

  • Tested with a mixed runlist containing a known-good ELF (simple_int8) and a timeout ELF (opcode_timeout) at configurable command indices. Verified that the driver now correctly reports the index of the hanging sub-command in both dmesg and the error_index returned to userspace via XRT.
  • Also tested all the hw tests in ve2 hw.

Signed-off-by: Bikash Singha <bisingha@xcobisingha50x.amd.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves VE2 runlist (ERT_CMD_CHAIN) timeout reporting by using CERT’s handshake progress field to populate error_index with the sub-command index that was actually in-flight when the timeout occurred, rather than always reporting index 0.

Changes:

  • Update ve2_cmd_wait() timeout path to read runlist_read_idx from CERT handshake memory and use it to set cc->error_index (with bounds-checking).
  • Rename the VE2 handshake field completion_status to runlist_read_idx to match firmware meaning.
  • Update debug dump output to print the renamed handshake field.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/driver/amdxdna/ve2_hwctx.c On timeout for command chains, reads CERT handshake runlist_read_idx to report the correct failing sub-command index and logs diagnostic details.
src/driver/amdxdna/ve2_host_queue.h Renames handshake field to runlist_read_idx to reflect its actual purpose (runlist progress).
src/driver/amdxdna/ve2_mgmt.c Updates handshake debug dump output to print runlist_read_idx.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@amd-gevadlam
Copy link
Collaborator

Can one of the admins verify this patch?

@chvamshi-xilinx chvamshi-xilinx merged commit d73913b into amd:main Mar 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants